package com.spring.modelandview;

import java.text.SimpleDateFormat;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.validation.BindException;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractCommandController;

public class UserRegisterController extends AbstractCommandController{
//	@Override
//	protected void initBinder(HttpServletRequest request,
//			ServletRequestDataBinder binder) throws Exception {
//		binder.registerCustomEditor(java.util.Date.class, new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true));
//	}
	@Override
	protected ModelAndView handle(HttpServletRequest request,
			HttpServletResponse response, Object cmd, BindException be)
			throws Exception {
		System.out.println(be.getErrorCount());
		System.out.println(be.getAllErrors());
		ModelAndView mav = new ModelAndView();
		mav.setViewName("success");
		mav.addAllObjects(be.getModel());
		return mav;
	}
	

}
